package com.tang.hawkmusic.api;

import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class ApiEngine {
    private volatile static Retrofit retrofit;
    private static   ApiEngine apiEngine;
    private static ApiService apiService;
    private ApiEngine(){
        retrofit=new Retrofit.Builder()
                 .baseUrl(ApiService.BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
    }
    public static ApiEngine getInstance(){
        if (apiEngine==null) {
            synchronized (ApiService.class){
                apiEngine=new ApiEngine();
            }
        }
        return apiEngine;
    }
    private Retrofit getRetrofit(){
        return retrofit;
    }
    public static ApiService getService(){
        if (apiService==null){
            apiService=getInstance().getRetrofit().create(ApiService.class);
        }
        return apiService;
    }
}
